package com.briup.corejava.day21;

import com.briup.corejava.day11.pojo.Student;

/**
 * 反射机制获取Class类型的对象 -> 字节码对象
 * 静态方法：Class.forName("全限类名");
 * 类名.class
 * 对象名.getClass()
 * 基本数据类型和数组类型属于特殊情况，但也可获得
 */
public class Test3 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class<?> c1 = Class.forName("com.briup.corejava.day11.pojo.Student");
        Class<Student> c2 = Student.class;
        Student s = new Student();
        Class<? extends Student> c3 = s.getClass();
        System.out.println(c1 == c2);
        System.out.println(c2 == c3);
        // 基本数据类型的Class对象
        Class<Integer> c4 = int.class;
        Class<Double> c5 = double.class;
        // 数组类型的Class对象
        String[] strings = new String[]{"hello","world"};
        int[] ints = new int[]{5,7,2,4};
        Class<String[]> c6 = String[].class;
        Class<?> c7 = ints.getClass();
    }
}
